<template>
  <div class="wrapper">
    <swiper :options="swiperOption" v-if="showSwiper">
      <!-- slides -->
      <swiper-slide v-for="item in list" :key="item.id">
        <img class="swiper-img" :src="item.imgUrl">
      </swiper-slide>
      <!-- Optional controls -->
      <div class="swiper-pagination"  slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
export default {
  name: 'HomeSwiper',
  props: {
    'list': Array
  },
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        loop: true
      }
      // swiperList: [
      //   {id: '001',
      //     imgUrl: 'https://imgs.aixifan.com/m6nal6PpIi-mQnQ3e-2AvQfi-VvUNZ3-2qIFjm.jpg?imageView2/1/w/482/h/247'
      //   },
      //   {id: '002',
      //     imgUrl: 'https://imgs.aixifan.com/SeTuDOzr3J-FjeeIr-22M3qq-2aQjMz-BnE7Rv.jpg?imageView2/1/w/482/h/247'
      //   }]
    }
  },
  computed: {
    showSwiper: function () {
      let show = this.list.length
      return show
    }
  }
}
</script>

<style lang="stylus" scoped>
  .wrapper >>> .swiper-pagination-bullet-active
    background white
  .wrapper
    overflow hidden
    width 100%
    height 0
    padding-bottom 31.25%
    background #eee
  .swiper-img
   width 100%
</style>
